import request from '@/utils/request'
import {localData} from 'kuan-utils'
const {get, set} = localData

const key = 'UPLOAD_TOKEN'

export async function fetchToken() {
  const localToken = get(key)
  if (localToken) return localToken

  const { data } = await request({
    url: '/api/dashboard/v1/uptoken'
  })

  set(key, data, 60 * 24)
  return data
}
